#!usr/bin/env python3
# -*- coding: utf-8

#布局管理
import sys
from PyQt5.QtWidgets import QApplication,QPushButton,QHBoxLayout,QVBoxLayout,QGridLayout
from base.CommonWin import BaseCenterWin
class MyWin(BaseCenterWin):
    def initUI(self):
        super().initUI()
        okBtn = QPushButton("确认")
        cancleBtn = QPushButton("取消")

        hBox = QHBoxLayout() #水平布局容器
        hBox.addStretch(3) #设置伸展因子 ，1 表示右下角
        hBox.addWidget(okBtn)
        hBox.addWidget(cancleBtn)
        self.setLayout(hBox)
        '''
        vBox = QVBoxLayout() #垂直布局容器
        vBox.addStretch(1) #并添加伸展因子，让水平布局显示在窗口底部
        vBox.addLayout(hBox)

        self.setLayout(vBox)
        #self.createGrid()
        '''

    def createGrid(self):
        grid = QGridLayout()
        self.setLayout(grid)

        names = ['Cls','Bck','','close',
                '7','8','9','/',
                '4','5','6','*',
                '1','2','3','-',
                '0','.','=','+']
        positions = [(i,j) for i in range(5) for j in range(4)]

        for  position,name in zip(positions,names):
            if name=='':
                continue
            btn = QPushButton(name)
            
            grid.addWidget(btn,*position) #参数为：组件，行，列;控件可以在网格中跨越多个行或列来布局

if __name__ == "__main__":
    app = QApplication(sys.argv)
    w = MyWin()
    w.show()

    sys.exit(app.exec_())